﻿<%@ CODEPAGE=65001 %>
<%
'///////////////////////////////////////////////////////////////////////////////
'// 插件应用:    Z-Blog 2.0 其它版本未知
'// 插件制作:    狼的旋律(http://www.wilf.cn) / zsx(http://www.zsxsoft.com)
'// 备    注:    相册分类图片上传和管理
'// 最后修改：
'// 最后版本:
'///////////////////////////////////////////////////////////////////////////////
%>
<% Option Explicit %>
<% 'On Error Resume Next %>
<% Response.Charset="UTF-8" %>
<% Response.Buffer=True %>
<!-- #include file="../../c_option.asp" -->
<!-- #include file="../../../zb_system/function/c_function.asp" -->
<!-- #include file="../../../zb_system/function/c_system_lib.asp" -->
<!-- #include file="../../../zb_system/function/c_system_base.asp" -->
<!-- #include file="../../../zb_system/function/c_system_plugin.asp" -->
<!-- #include file="../p_config.asp" -->
<%
Call System_Initialize()
Call WindsPhoto_Initialize()

Call CheckReference("")

If BlogUser.Level>2 Then Call ShowError(6)
If CheckpluginState("windsphoto") = False Then Call ShowError(48)

BlogTitle = "WindsPhoto 上传/管理"
%>
<!--#include file="..\..\..\zb_system\admin\admin_header.asp"-->
<script type="text/javascript" src="../../../zb_system/ADMIN/ueditor/ueditor.config.asp"></script>
<script type="text/javascript" src="../../../zb_system/ADMIN/ueditor/ueditor.all.min.js"></script>
<style type="text/css">
img.wp_top{border:1px solid #FFFFFF;margin:0 0 5px 0;max-width:<%=WP_SMALL_WIDTH%>px;max-height:<%=WP_SMALL_HEIGHT%>px;}
.syn_qq, .syn_tqq, .syn_qq_check, .syn_tqq_check{display:inline-block;margin-top:3px;width:19px;height:19px;line-height:64px;overflow:hidden;vertical-align:top;cursor:pointer;background: transparent url(../qqconnect/resources/connect_post_syn.png) no-repeat 0 0;}.syn_tqq{background-position: 0 -22px;margin-left: 5px;}.syn_qq_check{background-position: -22px 0;}.syn_tqq_check{background-position: -22px -22px;margin-left: 5px;}
</style>
<!--#include file="..\..\..\zb_system\admin\admin_top.asp"-->
<div id="divMain"><div id="ShowBlogHint"><%Call GetBlogHint()%></div>
	<div class="divHeader"><%=BlogTitle%></div>
    <div class="SubMenu"><%=WindsPhoto_SubMenu(0)%></div>
    <div id="divMain2">
		<script type="text/javascript">ActiveLeftMenu("aWindsPhoto")</script>
<%
Dim typeid,temprs,albumname
If IsNumeric(Request.QueryString("typeid")) = False Then
    Call SetBlogHint_Custom("!! 参数错误.")
    Response.Redirect"admin_main.asp"
Else
    typeid = CInt(Request.QueryString("typeid"))
End If

Set temprs = objConn.Execute("SELECT * FROM WindsPhoto_zhuanti where id="&typeid)
albumname = temprs("name")
If temprs.EOF And temprs.bof Then
    Call SetBlogHint_Custom("!! 还没有该相册.")
    Response.Redirect"admin_main.asp"
End If
%>
		<form id="edit" name="edit" action="admin_uploadpic.asp" method="post" enctype="multipart/form-data" onSubmit="return CheckForm()">
		<div class="content-box"><!-- Start Content Box -->
			<div class="content-box-header">
				<ul class="content-box-tabs">
					<li><a href="#fragment-1" onclick="if(document.getElementById('moreupload').style.display=='block' || document.getElementById('remoteupload').style.display=='block'){document.getElementById('moreupload').style.display='none';document.getElementById('remoteupload').style.display='none';document.getElementById('localupload').style.display='block';};return false;" class="default-tab"><span>图片上传</span></a></li>
					<li><a href="#fragment-2" onclick="if(document.getElementById('moreupload').style.display=='none'){document.getElementById('localupload').style.display='block';document.getElementById('moreupload').style.display='block';document.getElementById('remoteupload').style.display='none';};return false;"><span>批量上传</span></a></li>
					<li><a href="#fragment-3" onclick="if(document.getElementById('remoteupload').style.display=='none'){document.getElementById('remoteupload').style.display='block';document.getElementById('localupload').style.display='none';document.getElementById('moreupload').style.display='none';};return false;"><span>远程图片</span></a></li>
					<li style="float:right;padding-right:100px;"><a href="#fragment-4" onclick="location.href='help.asp#ad'"><span>广告 – </span><span style="font-size:12px;color:#15c;" title="当前为WindsPhoto免费版，Pro版无广告，且支持Flash控件批量上传。广告内容以照片、相册等相关的商品为主。">为何显示该广告？</span></a></li>
				</ul>
				<div class="clear"></div>
			</div>
			<div class="content-box-content" style="border:1px solid #E1E1E1;padding-left:5px;">
				<div style="width:250px;height:250px;float:right;margin:10px 10px 0 0;">
					<script type="text/javascript" >BAIDU_CLB_SLOT_ID = "596519";</script>
					<script type="text/javascript" src="http://cbjs.baidu.com/js/o.js"></script>
				</div>
				<p>标题：<input type="text" name="name" id="name" maxlength="50" size="40" /> <a href="#" onclick="if(document.getElementById('upload_setting').style.display=='none'){document.getElementById('upload_setting').style.display='block';}return false;" title="仅对本地上传有效，对远程图片无效">设置↓</a></p>
				<div style="display:none;" id="remoteupload">
					<p>地址：<input type="text" name="url" maxlength="120" size="40" /> <span style="color:red;">(*)必填</span></p>
					<p>缩图：<input type="text" name="surl" maxlength="120" size="40" /> </p>
				</div>
				<div style="display:block;" id="localupload">
					<p id="upload_setting" style="display:none;">照片质量：<input type="text" name="jpeg_width" id="jpeg_width" size="6" value="<%=WP_JPEG_WIDTH%>" title="自定义" <%=IIf(WP_JPEG_MAXWIDTH=True,"readonly","")%> /><span style="color:#a8a8a8;margin:0 3px 0 -20px;">px</span> <input type="checkbox" name="resize" id="resize" value="0" onclick="ClickResize()" <%=IIf(WP_JPEG_MAXWIDTH=True,"checked","")%> /><label for="resize">原图</label> | <%If WP_If_ASPJPEG=True Then%><input type="checkbox" name="automark" id="automark" <%=IIf(WP_WATERMARK_AUTO=True,"checked","")%> value="1" /><%End If%><label for="automark">水印</label> <input type="checkbox" name="autoname" id="autoname" <%=IIf(WP_UPLOAD_RENAME=True,"checked","")%> value="1" /><label for="autoname">文件重命名</label>
					<%If CheckpluginState("QQConnect") = True Then%>
					<a title="未设置同步至腾讯微博" class="syn_tqq" href="javascript:void(0);" id="connectPost_syntQQ">腾讯微博</a><input type="hidden" name="syn_tqq" id="syn_tqq" value="0"/>
<script type="text/javascript">
qqconnect_synTState = true;
var qqconnect_syntQQ = $("#connectPost_syntQQ");
function qqconnect_changestate1() {
	if (qqconnect_synTState) {
		qqconnect_syntQQ.removeClass("syn_tqq_check");
		qqconnect_syntQQ.addClass("syn_tqq");
		qqconnect_syntQQ.attr("title","未设置同步至腾讯微博");
		$("#syn_tqq").attr("value", "0");
		qqconnect_synTState = false;
	} else {
		qqconnect_syntQQ.removeClass("syn_tqq");
		qqconnect_syntQQ.addClass("syn_tqq_check");
		qqconnect_syntQQ.attr("title", "已设置同步至腾讯微博");
		$("#syn_tqq").attr("value", "1");
		qqconnect_synTState = true;
	}
};
$(document).ready(function() {
qqconnect_changestate1();
qqconnect_syntQQ.click(function(){qqconnect_changestate1()});
});
</script>
					<%End If%>
					</p>
					<p>上传：<input type="file" name="file0" size="40" accept="image/*" /> <font color="red">(*)必填</font></p>
				</div>
				<div style="display:none;" id="moreupload">
					<p>更多：<input type="file" name="file1" size="40" accept="image/*" /></p>
					<p>更多：<input type="file" name="file2" size="40" accept="image/*" /></p>
					<p>更多：<input type="file" name="file3" size="40" accept="image/*" /></p>
					<p>更多：<input type="file" name="file4" size="40" accept="image/*" /></p>
				</div>
				<p>照片简介:<br />
					<div><textarea name="photointro" id="editor_ue" style="width:500px;"></textarea></div>
				</p>
				<p>
					<input type="submit" id="upupup" value="提交" name="submit" class="button" />
					<input type="reset" id="reset" value="重置" name="reset" class="button" />
					<input type="hidden" name="zhuanti" id="zhuanti" value="<%=typeid%>" />
					<input type="hidden" name="category" value="<%=albumname%>" />
					<input type="hidden" name="act" value="upload" />
				</p>
			</div>
			</form>
		</div>
<%
Dim sql,rs,id,name,surl,hot,i,ipagecount,ipagecurrent,irecordsshown,a,b

If request.querystring("page") = "" Then
    ipagecurrent = 1
Else
    ipagecurrent = CInt(request.querystring("page"))
End If

If WP_ORDER_BY="0" Then
    sql = "SELECT * FROM WindsPhoto_desktop where zhuanti="&typeid&" ORDER BY id asc"
Else
    sql = "SELECT * FROM WindsPhoto_desktop where zhuanti="&typeid&" ORDER BY id desc"
End If
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, objConn, 1, 1
rs.pagesize = 24
ipagecount = rs.pagecount
If ipagecurrent > ipagecount Then ipagecurrent = ipagecount
If ipagecurrent < 1 Then ipagecurrent = 1
If ipagecount <> 0 Then
	Set temprs=objConn.Execute("select count(*) as C FROM WindsPhoto_desktop where zhuanti="&typeid)
	Response.Write"<p style='margin-top:10px;' id='manage'>已有"&temprs("C")&"张图片:</div>"
	Response.Write"<table width='100%' border='0' cellspacing='0' align='center'>"
    rs.absolutepage = ipagecurrent
    irecordsshown = 0
    Do While irecordsshown<24 and Not rs.EOF
		Response.Write "<tr align='center'>"
		For i = 1 To 4
			If Not rs.EOF Then
				id = rs("id")
				surl = rs("surl")
				name = rs("name")
				hot = rs("hot")
%>
<td width="25%"><img class="wp_top" src="<%=surl%>" title="<%=name%>" id="edtPic<%=id%>" onclick="ClickPic(<%=id%>)" /><input type="checkbox" id="edtDel<%=id%>" name="edtDel" value="<%=id%>" style="display:none;" /><div><%If hot=0 Or IsNull(hot)=True Then%><a href="admin_cmd.asp?action=sethot&id=<%=id%>&typeid=<%=typeid%>">封面</a><%Else%><span style="color:red">封面</span><%End If%>|<a href="admin_editphoto.asp?action=edit&id=<%=id%>">编辑</a>|<a onclick="Javascript:if(confirm('确定要删除吗?')){return true;}else{return false;}" href="admin_cmd.asp?action=delphoto&id=<%=id%>&typeid=<%=typeid%>">删除</a></div></td>
<%
				irecordsshown = irecordsshown + 1
				rs.movenext
			End If
		Next
		Response.Write"</tr>"
	Loop

	Response.Write"</table><hr />"

	Response.Write"<p><form id='frmBatch' method='post' action='admin_cmd.asp?typeid="&typeid&"'><input class='button' type='submit' onclick=""BatchDeleteAll('edtBatch');if(document.getElementById('edtBatch').value && document.getElementById('action').value){return window.confirm('单击“确定”继续。单击“取消”停止。');}else{return false}"" value='提交批量操作' id='btnPost'/><input type='hidden' id='edtBatch' name='edtBatch' value=''/><input type='checkbox' name='checkBatchdel' id='checkBatchdel' onclick=""ClickDelbox()"" /><label for='checkBatchdel'>删除</label> <input type='hidden' name='action' id='action' value=''/><select name='new_typeid' id='new_typeid' onchange=""document.getElementById('action').value='batchmove'""><option value=''>移动到分类</option>"

	Set temprs = objConn.Execute("SELECT * FROM WindsPhoto_zhuanti order by ordered,id asc")
	Do While Not temprs.EOF
		Response.Write"<option value='"&temprs("id")&"'>"&temprs("name")&"</option>"
		temprs.movenext
	Loop
	Set temprs = Nothing

	Response.Write"</select><span><a href='javascript:void(0);' title='单击图片进行选择'>？</a></span></form></p>"

	'分页
	If ipagecount >1 Then
		Response.Write"<hr/><p class=""pagebar"">分页：<a title='首页' href='?typeid="&typeid&"&page=1'>1</a> "
		If ipagecurrent=1 Then
			Response.Write"<a title='上一页'>«</a> "
		Else
			Response.Write"<a href='?typeid="&typeid&"&page="&ipagecurrent-1&"' title='上一页'>«</a> "
		End If

		If ipagecount>ZC_PAGEBAR_COUNT Then
			a=ipagecurrent-Cint((ZC_PAGEBAR_COUNT-1)/2)
			b=ipagecurrent+ZC_PAGEBAR_COUNT-Cint((ZC_PAGEBAR_COUNT-1)/2)-1
			If a<=1 Then
				a=1:b=ZC_PAGEBAR_COUNT
			End If
			If b>=ipagecount Then
				b=ipagecount:a=ipagecount-ZC_PAGEBAR_COUNT+1
			End If
		Else
			a=1:b=ipagecount
		End If

		For i = a to b
			If ipagecurrent = i Then
				Response.Write"<span>"&i&"</span> "
			Else
				Response.Write"<a href='?typeid="&typeid&"&page="&i&"'>"&i&"</a> "
			End If
		Next

		If ipagecount>ipagecurrent Then
			Response.Write"<a href='?typeid="&typeid&"&page="&ipagecurrent+1&"' title='下一页'>»</a> "
		Else
			Response.Write"<a title='下一页'>»</a> "
		End If
		Response.Write"<a title='尾页' href='?typeid="&typeid&"&page="&ipagecount&"'>"&ipagecount&"</a></div>"
	End If

End If
%>
	</div>
</div>
<script type="text/javascript">
// <![CDATA[
function CheckForm(){
	var filepath=document.edit.file0.value;
	if ((document.edit.file0.value.length == 0) && (document.edit.url.value.length == 0)) {
		alert("一个也没填?!");
		document.edit.file0.focus();
		return false;
	}else if(document.edit.url.value.length == 0){
		var fileArr=filepath.split("\\");
		var fileTArr=fileArr[fileArr.length-1].toLowerCase().split(".");
		var filetype=fileTArr[fileTArr.length-1];
		if(filetype!="jpg"&&filetype!="jpeg"&&filetype!="gif"&&filetype!="png"){
			alert("只可以上传图片文件，jpg、jpeg、gif、png。");
			return false;
		}
	}
	document.getElementById("upupup").value = "上传中...";
	document.getElementById("upupup").disabled=true;
	return true;
}

function ClickPic(id){
	var edtDelID="edtDel"+id;
	var edtPic="edtPic"+id;
	if(document.getElementById(edtDelID).checked==true){
		document.getElementById(edtDelID).value="";
		document.getElementById(edtDelID).checked=false;
		document.getElementById(edtPic).style.border="1px solid #FFFFFF";
		document.getElementById(edtPic).style.opacity="1";
		document.getElementById(edtPic).style.filter="alpha(opacity=100)";//IE
	}else{
		document.getElementById(edtDelID).value=id;
		document.getElementById(edtDelID).checked=true;
		document.getElementById(edtPic).style.border="1px solid #3399CC";
		document.getElementById(edtPic).style.opacity="0.7";
		document.getElementById(edtPic).style.filter="alpha(opacity=70)";//IE
	}
}

function ClickDelbox(){
	var checkBatchDel=document.getElementById("checkBatchdel");
	if(checkBatchDel.checked==true){
		document.getElementById("new_typeid").disabled=true;
		document.getElementById("action").value="batchdel";
	}
	else{
		document.getElementById("new_typeid").disabled=false;
		if(document.getElementById("new_typeid").value){
			document.getElementById("action").value="batchmove";
		}else{
			document.getElementById("action").value="";
		}
	}
}

function ClickResize(){
	var resize=document.getElementById("resize");
	if(resize.checked==true){
		document.getElementById("jpeg_width").setAttribute("readonly",'true');
	}
	else{
		document.getElementById("jpeg_width").removeAttribute("readonly");
	}
}

$(document).ready(function(){
	$("#edit").submit(function(){
		if(editor.queryCommandState("source")==1) editor.execCommand("source");
	}) //源码模式下保存时必须切换
});

var EditorOption = {
	toolbars:[['Source','fontsize','bold','italic','forecolor','emotion','blockquote','link','removeformat','formatmatch','autotypeset','insertorderedlist','insertunorderedlist','pasteplain']],
	autoHeightEnabled:false,
	initialFrameHeight:150
};
var editor=UE.getEditor('editor_ue',EditorOption);
// ]]>
</script>
<!--#include file="..\..\..\zb_system\admin\admin_footer.asp"-->
<%Call System_Terminate()%>